begintownscript;

variables;
short bmessage,rctx,rcty,which_1st,pcs,seated;
string custom_m;

body;

beginstate INIT_STATE;

	set_total_visibility(1);
	activate_hidden_group(1);
	which_1st = get_ran(1,1,4);
	if(which_1st == 1){
		pcs = 0;
		seated = 0;
		while(pcs <= 3){
			if(char_ok(pcs) == TRUE){
				set_character_facing(pcs,0);
				if(seated == 0)
					relocate_character(pcs,24,21);
				if(seated == 1)
					relocate_character(pcs,24,22);
				if(seated == 2)
					relocate_character(pcs,23,22);
				if(seated == 3)
					relocate_character(pcs,25,22);
				seated = (seated + 1);
			}

			pcs = (pcs + 1);
		}
	}
	if(which_1st == 2){
		relocate_character(6,24,30);
		set_character_facing(6,0);
		pcs = 0;
		seated = 0;
		while(pcs <= 3){
			if(char_ok(pcs) == TRUE){
				set_character_facing(pcs,4);
				if(seated == 0)
					relocate_character(pcs,24,27);
				if(seated == 1)
					relocate_character(pcs,24,26);
				if(seated == 2)
					relocate_character(pcs,25,26);
				if(seated == 3)
					relocate_character(pcs,23,26);
				seated = (seated + 1);
			}

			pcs = (pcs + 1);
		}
	}
	if(which_1st == 3){
		relocate_character(6,18,24);
		set_character_facing(6,6);
		pcs = 0;
		seated = 0;
		while(pcs <= 3){
			if(char_ok(pcs) == TRUE){
				set_character_facing(pcs,2);
				if(seated == 0)
					relocate_character(pcs,21,24);
				if(seated == 1)
					relocate_character(pcs,22,24);
				if(seated == 2)
					relocate_character(pcs,22,23);
				if(seated == 3)
					relocate_character(pcs,22,25);
				seated = (seated + 1);
			}

			pcs = (pcs + 1);
		}
	}
	if(which_1st == 4){
		relocate_character(6,30,24);
		set_character_facing(6,2);
		pcs = 0;
		seated = 0;
		while(pcs <= 3){
			if(char_ok(pcs) == TRUE){
				set_character_facing(pcs,6);
				if(seated == 0)
					relocate_character(pcs,27,24);
				if(seated == 1)
					relocate_character(pcs,26,24);
				if(seated == 2)
					relocate_character(pcs,26,25);
				if(seated == 3)
					relocate_character(pcs,26,23);
				seated = (seated + 1);
			}

			pcs = (pcs + 1);
		}
	}
	rcty = 37;
	while(rcty >= 24){
		force_view_center(24,rcty);
		force_instant_terrain_redraw();
		pause(2);

		rcty = (rcty - 1);
	}
	pause(4);

	play_sound(13);

	reset_dialog();
	if(party_size() == 1)
		add_dialog_str(0,"Sounds of death seem to fill the air like ambience.  The Immortal is staring me down.",0);
	if(party_size() > 1)
		add_dialog_str(0,"Sounds of death seem to fill the air like ambience.  The Immortal is staring us down.",0);
	add_dialog_str(1,"_You are at the end of your line.  I am The Immortal, and you shall die!_",0);
	add_dialog_choice(0,"The Immortal dies today!");
	bmessage = run_dialog(1);

	erase_char(6);
	if(which_1st == 1){
		set_terrain(24,17,0);
		activate_hidden_group(2);
		relocate_character(7,24,17);
		put_boom_on_space(24,17,0,2);
		put_boom_on_space(24,17,0,2);
		put_boom_on_space(24,17,0,2);
		force_instant_terrain_redraw();
		run_animation_sound(5);
	}
	if(which_1st == 2){
		set_terrain(24,31,0);
		activate_hidden_group(3);
		relocate_character(8,24,31);
		put_boom_on_space(24,31,5,0);
		force_instant_terrain_redraw();
		run_animation_sound(52);
	}
	if(which_1st == 3){
		set_terrain(17,24,0);
		activate_hidden_group(4);
		relocate_character(9,17,24);
		put_effect_on_space(17,24,13,4,1);
		force_instant_terrain_redraw();
		run_animation_sound(17);
	}
	if(which_1st == 4){
		set_terrain(31,24,0);
		activate_hidden_group(5);
		relocate_character(10,31,24);
		put_boom_on_space(31,24,7,0);
		force_instant_terrain_redraw();
		run_animation_sound(71);
	}
	pause(3);
	block_entry(1);
	set_incidental_sound(0);

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;

	block_entry(1);

break;

beginstate 11;

	if((get_flag(23,1) > 0) && (is_combat() == FALSE)){
		force_view_center(24,17);
		force_instant_terrain_redraw();
		pause(4);

		activate_hidden_group(7);
		relocate_character(12,24,17);
		put_boom_on_space(24,17,2,0);
		force_instant_terrain_redraw();
		run_animation_sound(10);
		pause(4);

		reset_dialog();
		add_dialog_str(0,"The robes are a different color, and his face is visible, but the presence is, if not stronger, the same:  Katothen.",0);
		add_dialog_str(1,"_You're okay...  that's good.  Hunter is in bad shape, but she told me to get to you as soon as possible.  I know everything that's been going on here._",0);
		add_dialog_str(2,"_It seems as if The Immortal has escaped.  No matter, though._",0);
		add_dialog_str(3,"What?  Escaped?  But he's dead, isn't he?",0);
		add_dialog_choice(0,"That's impossible!  The Immortal is dead!");
		bmessage = run_dialog(1);

		reset_dialog();
		add_dialog_str(0,"_No, he's not.  It's no illusion-- up until the moment you saw him keel over, you were fighting the real deal.  The person who died, however, was merely a simulacrum._",0);
		add_dialog_str(1,"_But it's alright.  I've observed a great deal of his fighting techniques.  We'll win next time for sure._",0);
		add_dialog_str(2,"This victory...  was for naught?",0);
		add_dialog_choice(0,"Yeah, sure, Katothen.  Let's hope so.");
		bmessage = run_dialog(1);

		play_sound(95);
		reset_dialog();
		if(party_size() == 1)
			add_dialog_str(0,"A voice is in my mind again.  And from the looks of things, it's in Katothen's too.  It's The Immortal.",0);
		if(party_size() > 1)
			add_dialog_str(0,"A voice is in our minds again.  And from the looks of things, it's in Katothen's too.  It's The Immortal.",0);
		add_dialog_str(1,"_Ah, Katothen.  Always a reckless child, yet never with an eye for strategy._",0);
		add_dialog_choice(0,"What are you talking about?");
		bmessage = run_dialog(1);

		move_to_new_town(25,24,24);
	}

break;
